package com.qyb.demo.thread;

import java.util.List;
import java.util.Map;

/**
 * <strong>实现功能:</strong>
 * <p></p>
 *
 * @author 秦有宝
 * @version 1.0.0  2019/1/21 17:25
 */
public class ManyThread2 extends Thread {

    private List<String> list;
    private Map<Long, Integer> map;

    public ManyThread2(List<String> list, Map<Long, Integer> map) {
        this.list = list;
        this.map = map;
    }

    @Override
    public void run() {

        int pcount = Runtime.getRuntime().availableProcessors();
        int i = map.get(Thread.currentThread().getId());

        for (; i < list.size(); i += pcount) {
            System.out.println(list.get(i));
        }
    }
}
